<?php
namespace app\login\controller;
use \app\check\controller\Check;
class Index extends Check
{

 	public function index(){

        return json(['code'=>200,'msg'=>'login-index-index']);
    }

    public function login()
    {
    	$login_type = (int)(input('login_type'));// 登陆方式
    	switch ($login_type) {
            // 微信登陆
            case 'wechat':
                $login = model('Wechat');
                $unionid = htmlspecialchars(input('unionid'));
                $where = ['unionid'=>$unionid];
                break;
            // 微博登陆
            case 'weibo':
                $login = model('Weibo');
                // $username = htmlspecialchars(input('username'));
                // $password = htmlspecialchars(input('password'));
                // $where = ['username'=>$username,'password'=>$password];
                break;
            // QQ登陆
            case 'qq':
                $login = model('Qq');
                // $username = htmlspecialchars(input('username'));
                // $password = htmlspecialchars(input('password'));
                // $where = ['username'=>$username,'password'=>$password];
                break;
            // 账号登陆
            case 'account':
            default:
            	$login = model('User');
                $username = htmlspecialchars(input('username'));
                $password = htmlspecialchars(input('password'));
                $where = ['username'=>$username,'password'=>$password];
                break;
        }
        $data = $login->where($where)->find();
        $login_ip = htmlspecialchars(request()->ip());// 登陆IP
        $login_time = time();// 登陆时间


    	return json(['code'=>200,'ip'=>$login_ip,'time'=>$login_time,'msg'=>'login-index-login']);
    }

    public function login_out()
    {
    	return json(['code'=>200,'msg'=>'login-index-login_out']);
    }
}	
